import React, { Component } from 'react'
import TheImage from "../TheImage";
import goBack from '@/assets/icons/goBack.png'
import './style/index.less'

class GoBack extends Component {
    goBack(){
        console.log(typeof this.props.history);
        if(typeof this.props.history ==='function'){
            this.props.history()
        }else{
            this.props.history && this.props.history.goBack()
        }
    }
    render() {
        const title = this.props.title || '';
        const extra = this.props.extra || '';
        return <header className='go-back-header'>
            <div onClick={() =>this.goBack()}
                style={{ display: 'flex', alignItems: 'center' }}>
                <TheImage preview={false} width={22} src={goBack} />
            </div>
            <div className={'go-back-title'}>{title}</div>
            <div className={'go-back-extra'}>{extra}</div>
        </header>
    }
}

export default GoBack
